package com.itheima.Test;

/*
    String toLowerCase() : 将当前字符串字母全部转为小写
    String toUpperCase() : 将当前字符串字母全部转为大写

    String trim(): 消除当前字符串的首尾的空格

    boolean contains(String str): 判断当前字符串是否包含指定的内容,包含返回true,不包含就返回false

    boolean startsWith(String str): 判断当前字符串是否以指定内容开头
    boolean endWith(String str):  判断当前字符串是否以指定内容结尾

    int indexOf(String str) : 获取指定内容在当前字符串中第一次出现的索引位置
 */
public class Test12 {
    public static void main(String[] args) {
        String s1 = "    good good study, day day up     ";
        System.out.println("s1 = " + s1);

        //需求一: 将s1转为全大写内容
        String s2 = s1.toUpperCase();
        System.out.println("s2 = " + s2);

        //需求二: 将s2转为全小写
        String s3 = s2.toLowerCase();
        System.out.println("s3 = " + s3);

        //需求三: 将s1首尾的空格消除掉
        String s4 = s1.trim();
        System.out.println("s4 =" + s4);

        //需求四: 判断ss中是否包含敏感词"fuck"
        //士可杀,不可辱
        String ss = "you can kill me, you can't fuck me~";
        boolean flag1 = ss.contains("fuck");
        System.out.println("flag1 = " + flag1);

        //需求五: 判断name是否姓德
        String name = "德玛西亚1";
        boolean flag2 = name.startsWith("德玛");
        System.out.println("flag2 = " + flag2);

        //需求六: 判断name是否以"亚"结尾
        boolean flag3 = name.endsWith("亚1");
        System.out.println("flag3 = " + flag3);

        //需求七: 获取str中"海"字第一次出现的索引位置
        String str = "上海的自来水来自海上";
        int index = str.indexOf("海");
        System.out.println("index = " + index);

    }
}
